package com.ourteam.workspace.api;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.workspace.dao.IWorkspaceBuildLogDAO;
import com.ourteam.workspace.dao.WorkspaceBuildLogDAOQueryBean;
import com.ourteam.workspace.domain.WorkspaceBuildLogBean;

public class WorkspaceBuildLogSearchModel extends AbstractSearchModel<WorkspaceBuildLogDAOQueryBean> {
	private long buildConfigId;

	public long getBuildConfigId() {
		return buildConfigId;
	}

	public void setBuildConfigId(long buildConfigId) {
		this.buildConfigId = buildConfigId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {

		return WorkspaceBuildLogBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(WorkspaceBuildLogDAOQueryBean queryBean) throws Exception {

		WorkspaceBuildLogDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		if (buildConfigId != 0) {
			criteria.andWorkspaceBuildConfigIdEqualTo(buildConfigId);
		}

		if (queryBean.getSortProperties().isEmpty()) {
			queryBean.setSortProperty(IWorkspaceBuildLogDAO.BuildTime, false);
		}
	}

}
